// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   WedgePolygon.java

package jones.rigid;


// Referenced classes of package jones.rigid:
//            ConvexPolygon

public class WedgePolygon extends ConvexPolygon
{

    public WedgePolygon(double x, double y, double orientation, double angle, double radius, int sides)
    {
        if (sides < 0 || sides == 0 && angle != 0.0D)
            throw new IndexOutOfBoundsException("sides <= 0");
        if (angle < -3.1415926535897931D || angle > 3.1415926535897931D)
            throw new IllegalArgumentException("angle = " + angle);
        if (radius == 0.0D)
        {
            n = 1;
            this.x = new double[n];
            this.y = new double[n];
            this.x[0] = x;
            this.y[0] = y;
            return;
        }
        if (angle == 0.0D)
        {
            n = 2;
            this.x = new double[n];
            this.y = new double[n];
            this.x[0] = x;
            this.y[0] = y;
            this.x[1] = x + radius * Math.cos(orientation);
            this.y[1] = y + radius * Math.sin(orientation);
            return;
        }
        this.x = new double[sides + 2];
        this.y = new double[sides + 2];
        this.x[0] = x;
        this.y[0] = y;
        double stepAngle = angle / (double)sides;
        for (int i = 0; i <= sides; i++)
        {
            double currentAngle = (double)i * stepAngle + orientation;
            this.x[i + 1] = radius * Math.cos(currentAngle) + x;
            this.y[i + 1] = radius * Math.sin(currentAngle) + y;
        }

        n = ConvexPolygon.convexHull(this.x, this.y, sides + 2);
        calculateBounds();
    }
}
